import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart

def Sender_text_yandex(message,subject,toad):
    sender='bishop.py@yandex.ru'
    to='bishop.py@yandex.ru'
    mail_coding = 'windows-1251'
    #-----------------------
    msg=MIMEMultipart()
    msg['Subject']=subject
    msg['From']=sender
    msg['To']=to
    #-----------------------
    MIME_text=MIMEText(message.encode('cp1251',errors='ignore'),'plain',mail_coding)
    msg.set_charset(mail_coding)
    msg.attach(MIME_text)
    #-----------------------
    serv_yd='smtp.yandex.ru'
    port='587'
    #-----------------------
    log='bishop.py'
    pas='bishop1987py'
    #-----------------------
    fro='bishop.py@yandex.ru'
    #-----------------------
    server=smtplib.SMTP(serv_yd,port)
    server.starttls()
    server.login(log,pas)
    server.sendmail(fro, toad, msg.as_string())
    server.quit()

def Sender_text_mailRu(message,subject,toad):
    sender='bishop.py@mail.ru'
    to='bishop.py@yandex.ru'
    mail_coding = 'windows-1251'
    #-----------------------
    msg=MIMEMultipart()
    msg['Subject']=subject
    msg['From']=sender
    msg['To']=to
    #-----------------------
    MIME_text=MIMEText(message.encode('cp1251',errors='ignore'),'plain',mail_coding)
    msg.set_charset(mail_coding)
    msg.attach(MIME_text)
    #-----------------------
    serv_mr='smtp.mail.ru'
    port='587'
    #------------------------
    log='bishop.py'
    pas='bishop1987py'
    #-----------------------
    fro='bishop.py@mail.ru'
    #-------------------------
    server=smtplib.SMTP(serv_mr,port)
    server.starttls()
    server.login(log,pas)
    server.sendmail(fro, toad, msg.as_string())
    server.quit()


def Test(message,subject='Test email',toad='Logrus_ak@ukr.net'):
    sender='bishop.py@yandex.ru'
    to='bishop.py@yandex.ru'
    mail_coding = 'windows-1251'
    #-----------------------
    msg=MIMEMultipart()
    msg['Subject']=subject
    msg['From']=sender
    msg['To']=to
    #-----------------------
    MIME_text=MIMEText(message.encode('cp1251',errors='ignore'),'plain',mail_coding)
    msg.set_charset(mail_coding)
    msg.attach(MIME_text)
    #-----------------------
    serv_yd='smtp.yandex.ru'
    port='587'
    #-----------------------
    log='bishop.py'
    pas='bishop1987py'
    #-----------------------
    fro='bishop.py@yandex.ru'
    #-----------------------
    server=smtplib.SMTP(serv_yd,port)
    server.starttls()
    server.login(log,pas)
    server.sendmail(fro, toad, msg.as_string())
    server.quit()


